<?php

namespace Apps\AppApi\Method\MyBranch;


use Apps\AppApi\Method\BaseMethod;
use Apps\Common\Models\BpFavorites;
use Apps\Common\Models\BeautyParlorService;

/**
 * 下架服务
 * @author      545
 * @date        2016年1月12日
 * @version     1.1.2
 * @copyright   Copyright 2015 meelier.com
 */
class OutSell extends BaseMethod
{
    public function run()
    {
    	if(false == $this->verifyUserAuth()){
    		return false;
    	}
    	$id = $this->getDataItem('id');
    	$branchid = $this->getDataItem('bp_id');
    	$userId = $this->getUserAuth()->userId;
    	$bp = BeautyParlorService::findFirst("service_id = {$id} and beauty_parlor_id = {$branchid} ");
    	
    	if($bp){

    	    if ($bp->update(['service_is_sell'=>-1,'service_addtime'=>date("Y-m-d H:i:s", time())])){
    	        $this->setResult(['success'=>1,'message'=>'下架成功！']);
    	    }
    		else {
    		    $this->setResult(['success'=>0,'message'=>'下架失败！']);
    		}
    	}else{
    		$this->setResult(['success'=>0,'message'=>'下架失败！']);
    	}
    }
}